package cc.autoapi.pucong.auto.flow.core.qlexpress.builder;

import cc.autoapi.pucong.auto.flow.core.qlexpress.entity.EntityBase;
import cc.autoapi.pucong.auto.flow.core.qlexpress.entity.EntityValueNode;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.CompareTypeEnum;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.ComputerTypeEnum;
import cc.autoapi.pucong.auto.flow.core.qlexpress.enumSelf.NodeTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

public class FlowLogicBuilder {

    @Getter
    private List<EntityBase> entityList;

    public FlowLogicBuilder() {
        entityList = new ArrayList<>();
    }

    public static FlowLogicBuilder start() {
        FlowLogicBuilder flowLogicBuilder = new FlowLogicBuilder();
        return flowLogicBuilder;
    }

    /**
     * 选择输入参数
     *
     * @param value
     * @return
     */
    public EntityValueNode choiceParams(String value) {
        EntityValueNode valueNode = new EntityValueNode();
        valueNode.setNodeType(NodeTypeEnum.变量);
        valueNode.addChoiceParam(value);
        return valueNode;
    }

    /**
     * 选择全局参数
     *
     * @param value
     * @return
     */
    public EntityValueNode choiceGlobal(String value) {
        EntityValueNode valueNode = new EntityValueNode();
        valueNode.setNodeType(NodeTypeEnum.变量);
        valueNode.addChoiceGlobal(value);
        return valueNode;
    }

    /**
     * 输入静态值
     *
     * @param value
     * @return
     */
    public EntityValueNode inputValue(String value) {
        EntityValueNode valueNode = new EntityValueNode();
        valueNode.setNodeType(NodeTypeEnum.变量);
        valueNode.addComputerInput(value);
        return valueNode;
    }

    public EntityValueNode addOperation(ComputerTypeEnum computerType) {
        EntityValueNode valueNode = new EntityValueNode();
        valueNode.setNodeType(NodeTypeEnum.变量);
        valueNode.addComputer(computerType);
        return valueNode;
    }

    public static void main(String[] args) {
        FlowLogicBuilder start = FlowLogicBuilder.start();
        EntityValueNode valueNode = start.choiceParams("12").addCompare(CompareTypeEnum.EQ).addChoiceGlobal("qwasdadrq");
        valueNode.then();
    }
}
